package com.edu.controller;

import com.edu.bean.Book;
import com.edu.bean.User;
import com.edu.service.BookService;
import com.edu.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class BookController {
    @Resource
    private BookService bookService;
    @RequestMapping("/index")
    public ModelAndView regis(User user){
        ModelAndView mv = new ModelAndView();
        List<Book> l=bookService.selectAll();
       mv.addObject("b",l);
       mv.setViewName("main.jsp");
       return mv;
    }

    @GetMapping ("/del")
    public String regis(int bId){
        System.out.println(bId);

            bookService.del(bId);

        return "/index";
    }
}
